<?php

namespace app\admin\model\fssy;

use think\Model;


class Nurseinfo extends Model
{

    // 表名
    protected $name = 'fssy_nurseinfo';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    // protected $updateTime = 'updatetime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'gender_data_text'
    ];

    public function dictsdepartment()
    {
        return $this->belongsTo('app\admin\model\dicts\Department', 'department_id')->setEagerlyType(0);
    }

    public function dictsjobtitle()
    {
        return $this->belongsTo('app\admin\model\dicts\Jobtitle', 'jobtitle_id')->setEagerlyType(0);
    }

    public function dictsusejobtitle()
    {
        return $this->belongsTo('app\admin\model\dicts\Jobtitle', 'use_jobtitle_id')->setEagerlyType(0);
    }

    public function dictsiniteducationbak()
    {
        return $this->belongsTo('app\admin\model\dicts\Educationbak', 'init_educationbak_id')->setEagerlyType(0);
    }

    public function dictseducationbak()
    {
        return $this->belongsTo('app\admin\model\dicts\Educationbak', 'educationbak_id')->setEagerlyType(0);
    }

    public function getGenderDataList()
    {
        return ['男' => __('Gender_data 男'), '女' => __('Gender_data 女')];
    }

    public function getOnJobList()
    {
        return ['在职' => __('在职'), '离职' => __('离职')];
    }


    public function getGenderDataTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['gender_data']) ? $data['gender_data'] : '');
        $list = $this->getGenderDataList();
        return isset($list[$value]) ? $list[$value] : '';
    }
}
